<%--
  User: dw
  Date: 2019/12/9
  Time: 16:32
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>添加部门</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../layuiadmin/style/admin.css" media="all">
</head>
<body>
<form class="layui-form" action="" id="addDep">
    <div class="layui-form-item">
        <label class="layui-form-label">部门编号</label>
        <div class="layui-input-block">
            <input type="text" name="depId" required  lay-verify="required" autocomplete="off" class="layui-input" readonly  placeholder="由系统自动生成" >
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">部门名称</label>
        <div class="layui-input-block">
            <input type="text" name="depName" required  lay-verify="required" placeholder="请输入部门名称" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">负责人工号</label>
        <div class="layui-input-block">
                <div class="layui-input-inline">
                    <select id="user" lay-filter="user" name="depleader">
                        <option value="1">2019122403</option>
                    </select>
                </div>
        </div>
    </div>
</form>

</body>
<script src="../../../layuiadmin/layui/layui.js"></script>
<script>
    layui.use(['layer','form','laydate'],function(){
        var layer = layui.layer;
        var laydate = layui.laydate;
        var  $ = layui.jquery;
        var form = layui.form;
        form.render();

        //文档加载时加载部门主管信息
        $(function () {
            //加载部门信息
            $.ajax({
                url: "/user/loadAll",
                data:{},
                dataType:"json",
                type:"post",
                success:function (res) {
                    var userList = res;

                    var str = "";
                    for(var i = 0;i < userList.length; i++){
                        var user = userList[i];
                        str += "<option value='"+user.userId+"'>"+user.userId+"</option>";
                    }
                    $("#user").html(str);
                    //必须重新加载
                    form.render();
                },
                error:function (e) {
                    console.log(e.responseText)
                }
            });
        });
    });



</script>
</html>
